import axios from '@/libs/api.request'

const prefix = '/web/subadmin'
const subAdminApi = {
  pageResult(trainCenterId, user) {
    return axios.request({
      url: prefix + '/pageResult/' + trainCenterId,
      data: user,
      method: 'post'
    })
  },
  saveOrUpdate(user) {
    return axios.request({
      url: prefix + "/saveOrUpdate",
      method: 'post',
      data: user
    })
  },
  saveOrUpdateMail(user) {
    return axios.request({
      url: prefix + "/mail/saveOrUpdate",
      method: 'post',
      data: user
    })
  },
  resetPwd(id, pwd, cmfpwd) {
    let params = {'pwd': pwd, 'cmfpwd': cmfpwd};
    return axios.request({
      url: prefix + '/resetPwd/' + id,
      method: 'put',
      params: params
    })
  },
  delete(id) {
    return axios.request({
      url: prefix + '/' + id,
      method: 'delete'
    })
  },
  getMenuTreeData(userId) {
    return axios.request({
      url: prefix + '/menu/' + userId,
      method: 'get'
    })
  },
  saveMenuTreeData(userId, menuIds) {
    return axios.request({
      url: prefix + '/menu/' + userId,
      method: 'post',
      data: {menuIds: menuIds}
    })
  }
}

export default subAdminApi
